//
// Created by EDZ on 2020/3/3.
//

#ifndef PUSHER_AUDIOCHANNEL_H
#define PUSHER_AUDIOCHANNEL_H

#include <cstdint>
#include <jni.h>
#include <sys/types.h>
#include <faac.h>
#include <rtmp.h>
#include <cstring>
#include "macro.h"

class AudioChannel {
    typedef void(*AudioCallback)(RTMPPacket *packet);
public:
    AudioChannel();

    virtual ~AudioChannel();

    void initAudioEncoder(int sample_rate, int channels);

    void encodeData(int8_t *data);

    int getInputSamples();

    void setAudioCallback(AudioCallback callback);

    RTMPPacket *getAudioSeqHeader();

private:
    int mChannels;
    u_long inputSamples;
    u_long maxOutputBytes;
    faacEncHandle audioEncoder = 0;
    u_char *buffer;
    AudioCallback audioCallback;
};


#endif //PUSHER_AUDIOCHANNEL_H
